//package com.jackrain.clouddata.oms.lts;
//
//import com.alibaba.dubbo.common.utils.NetUtils;
//import com.github.ltsopensource.core.domain.Action;
//import com.github.ltsopensource.tasktracker.Result;
//import com.github.ltsopensource.tasktracker.logger.BizLogger;
//import com.github.ltsopensource.tasktracker.runner.JobContext;
//import com.github.ltsopensource.tasktracker.runner.JobRunner;
//import com.jackrain.nea.config.PropertiesConf;
//import com.jackrain.clouddata.oms.dao.LogStageDao;
//import com.jackrain.clouddata.oms.util.DateUtils;
//import com.jackrain.clouddata.oms.util.ExceptionUtil;
//import com.jackrain.nea.util.ApplicationContextHandle;
//import lombok.extern.slf4j.Slf4j;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//import java.util.concurrent.ConcurrentHashMap;
//
///**
// * Created by nathan on 2016/9/8.
// */
//@Slf4j
//public class JobRunnerDispatcher implements JobRunner {
//
//    private static Logger logger = LoggerFactory.getLogger(JobRunnerDispatcher.class.getName());
//
//    private static final ConcurrentHashMap<String, JobRunner> JOB_RUNNER_MAP = new ConcurrentHashMap<String, JobRunner>();
//
//
//    static {
//        JOB_RUNNER_MAP.put("order", new JobRunnForOrder());
//    }
//
//    @Override
//    public Result run(JobContext jobContext) throws Throwable {
//        String type = jobContext.getJob().getParam("type");
//        if (!JOB_RUNNER_MAP.containsKey(type))
//            return null;
//        return JOB_RUNNER_MAP.get(type).run(jobContext);
//    }
//
//
//    /**
//     * 淘宝订单任务
//     */
//    static class JobRunnForOrder implements JobRunner {
//        @Override
//        public Result run(JobContext jobContext) throws Throwable {
//            try {
//                BizLogger bizLogger = jobContext.getBizLogger();
//                log.debug("JobRunnForOrder start online!");
//                bizLogger.info("JobRunnForOrder start online!");
//            } catch (Exception e) {
//                log.error("Run job failed!", e);
//                PropertiesConf pconf = (PropertiesConf) ApplicationContextHandle.getBean("propertiesConf");
//                LogStageDao logstage = ApplicationContextHandle.getBean(LogStageDao.class);
//                String tag = pconf.getProperty("ons.comp", "aokang");
//                String topic = pconf.getProperty("ons.orderTopic", "TAOBAO_ORDER");
//                String errmsg = ExceptionUtil.getExceptionAllinformation(e);
//                String server_ip =NetUtils.getLocalAddress().getHostAddress();
//                logstage.addServerErrLog(topic, tag, errmsg,server_ip);
//                return new Result(Action.EXECUTE_FAILED, e.getMessage());
//            }
//            return new Result(Action.EXECUTE_SUCCESS, "Run JobRunnForOrder online success!");
//        }
//    }
//}
